/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 *    
 */

package org.vineatoum.business.configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;

import org.vineatoum.view.utils.jtablecustom.TableListener;

@XmlRootElement(name = "maturityMeasureType")
@XmlAccessorType(XmlAccessType.FIELD)
public class MaturityMeasureType extends TableListener {
	public static List<MaturityMeasureType> maturityMeasurementTypes = new ArrayList<MaturityMeasureType>();
	@XmlID
	@XmlAttribute
	private String name;

	public MaturityMeasureType() {
		maturityMeasurementTypes.add(this);
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	@Override
	public TableListener getNewInstance() {
		return new MaturityMeasureType();
	}

	@Override
	public Vector<Object> getVectorData() {
		Vector<Object> vector = new Vector<Object>();
		vector.add(name);
		return vector;
	}

	@Override
	public void updateField(String field, Object value) {
		try {
			name = (String) value;
		} catch (ClassCastException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	@Override
	public Vector<String> getVectorColumns() {
		Vector<String> columnMeasurementType = new Vector<String>();
		columnMeasurementType.add("Type");

		return columnMeasurementType;
	}

	@Override
	public String toString() {
		return name;
	}
}
